<template>
	<view class="content">



		<ComplainList v-if="currentPage==1" :params="shop_id" ></ComplainList>
		<OrderList v-if="currentPage==3" :resh="resh" :params="shop_id"></OrderList>
		<shopHome v-show="currentPage==0" :params="shop_id"></shopHome>
		<Cart class="cartBox" :shopId="shop_id" v-if="currentPage==2" ></Cart>


		<view class="cu-bar tabbar bg-white shadow foot" style="background-color: white;">
			<view class="action " data-cur="basics" v-for="(item,index) in tabBar" @click="navTo(index)">
				<view class='cuIcon-cu-image text-bar'>
					<image class="animation-scale-up" :src="index== currentPage?item.imgClick:item.imgNormal"
						mode="aspectFit"></image>
					<view class="cu-tag badge" v-if="item.badge && Object.keys(cartInfo.goodsList).length>0">
						{{Object.keys(cartInfo.goodsList).length}}
					</view>
				</view>
				<view :class="index== currentPage?'text-blue':'text-gray'" class="text-bar navFont1">{{item.text}}
				</view>
			</view>
		</view>

	</view>
</template>
<script>
	import ComplainList from "./complaintList.vue"
	import OrderList from './orderList.vue'
	import shopHome from "./shop.vue"
	import Cart from "./cart.vue"

	export default {
		components: {
			Cart,
			ComplainList,
			OrderList,
			shopHome,

		},
		data() {
			return {
				currentPage: 0,
				shop_id: -1,
				params: null,
				cartInfo: {
					goodsList: []
				},
				status:-1,
				resh: "",
				tabBar: [{
						url: '',
						text: '好货',
						badge: false,
						imgNormal: this.resDomain + '/static/img/tabbar/home.png',
						imgClick: this.resDomain + "/static/img/tabbar/home1.png",
					},
					{
						url: '',
						text: '评价',
						badge: false,
						imgNormal: this.resDomain + '/static/img/tabbar/pinjia_no.png',
						imgClick: this.resDomain + '/static/img/tabbar/pinjia.png',
					},
					{
						url: '',
						text: '购物车',
						badge: true,
						imgNormal: this.resDomain + '/static/img/tabbar/chart.png',
						imgClick: this.resDomain + '/static/img/tabbar/chart1.png',
					},
					{
						url: '',
						text: '订单',
						badge: false,
						imgNormal: this.resDomain + '/static/img/tabbar/order.png',
						imgClick: this.resDomain + '/static/img/tabbar/order1.png',
					}
				],

			}
		},
		onLoad(option) {

			let params = JSON.parse(option.params);
			this.shop_id = params[0].value;



		},

		onShow() {
            this.upData();
			this.updateCartInfo();
		},

		methods: {
			upData() {
				this.resh = false;
				switch (this.currentPage) {
					
					case 3:
						let time = new Date().getTime(); //获取当前的毫秒数
						this.resh = time;
						break;

				}
			},
			updateCartInfo() {
				const res1 = uni.getStorageSync('cartInfo-' + this.shop_id);
				if (res1) {
					this.cartInfo = res1
				} else {
					this.$set(this.cartInfo, 'total_goods_price', 0)
					this.$set(this.cartInfo, 'goodsList', {})
					this.$set(this.cartInfo, 'total_num', 0)
					this.$set(this.cartInfo, 'goods_real_price', 0)
				}
				
			},


			jumpTo(res) {
				uni.navigateTo({
					url: "./info"
				})
			},
			navTo(index) {
				this.currentPage = index;
			},

		}
	}
</script>

<style scoped>
	.navFont1 {
		font-size: calc(100vw*(20/750));
	}
</style>
